package junior.util.mapstruct;

import org.apache.commons.lang3.BooleanUtils;

/**
 * Name: TypeConversionStrategy
 * Function: 类型转换策略
 *
 * @Author: K.K
 * Create Time: 2020/12/08 14:08
 * Modified By:
 * Modified Time:
 * Description:
 * Version:
 */
public class TypeConversionStrategy {

    public Integer booleanToInteger(Boolean value) {
        if (null == value) {
            return null;
        }
        return BooleanUtils.isTrue(value) ? 1 : 0;
    }

    public Boolean integerToBoolean(Integer value) {
        if (null == value) {
            return null;
        }
        return value == 1;
    }

    public Integer longToInteger(Long value) {
        return null != value ? value.intValue() : null;
    }

    public Long integerToLong(Integer value) {
        return null != value ? value.longValue() : null;
    }
}
